import type { YNABConstants } from '../window/ynab-constants';
import type { DateWithoutTime } from '../window/ynab-utilities';
import type { YNABAccount } from './account';
import type { YNABPayee } from './payee';
import type { YNABSubCategory } from './sub-category';

export interface YNABTransaction {
  accepted: boolean;
  account: YNABAccount;
  accountName: string;
  accountId: string;
  amount: number;
  baseSubTransactions: Array<YNABTransaction>;
  budgetVersionId: string;
  cashAmount: number;
  checkNumber: string | null;
  cleared: keyof YNABConstants['TransactionState'];
  creditAmount: number;
  creditAmountAdjusted: number;
  date: DateWithoutTime;
  dateEnteredFromSchedule: DateWithoutTime | null;
  entityId: string;
  flag: string | null;
  importedDate: DateWithoutTime | null;
  importedPayee: YNABPayee | null;
  isScheduledSubTransaction?: boolean;
  isScheduledTransaction?: boolean;
  isSplit?: boolean;
  isTombstone?: boolean;
  isOnBudgetTransfer?: boolean;
  matchedTransaction: YNABTransaction | null;
  matchedTransactionId: string | null;
  memo: string;
  month: string;
  originalImportedPayee: YNABPayee | null;
  parentTransaction?: YNABTransaction;
  parentEntityId?: string;
  payee: YNABPayee | null;
  payeeId: string | null;
  payeeName: string;
  scheduledTransactionId: string | null;
  scheduledTransaction: YNABTransaction | null;
  source: keyof YNABConstants['TransactionSource'] | null;
  subCategory: YNABSubCategory | null;
  subCategoryCreditAmountPreceding: number;
  subCategoryId: string | null;
  subCategoryNameWrapped: string;
  subTransactions: YNABTransaction[];
  transferAccountId: string | null;
  transferAccounts: YNABAccount[] | null;
  transferSubTransaction: YNABTransaction | null;
  transferSubTransactionId: string | null;
  transferTransaction: YNABTransaction | null;
  transferTransactionId: string | null;
  ynabId: string | null;
  inflow: number;
  outflow: number;

  isUncleared?: () => boolean;
  isReconciled?: () => boolean;
  get: <T extends keyof YNABTransaction>(key: T) => YNABTransaction[T];
}
